#!/bin/sh

dhcpcd

if="enp5s0"
netns="ttserver"

(ip netns pids $etns | xargs kill -9) 2>/dev/null
(ip netns del $netns && sleep 1) 2>/dev/null

ip netns add $netns || exit 1
ip netns exec $netns ip link set lo up || exit 1

ip link set dev $if netns $netns || exit 1
ip netns exec $netns ip link set $if up || exit 1
ip netns exec $netns ip addr add 192.168.3.81/24 dev $if || exit 1
ip netns exec $netns ip route replace default via 192.168.3.1 dev $if || exit 1
ip netns exec $netns /usr/local/bin/ttserver \
    --serv-addr=192.168.3.81 \
    --serv-port=9527 \
    --image-path=/dev/zvol/zroot/tt \
    --cpu-total=24 \
    --mem-total=$[48 * 1024] \
    --disk-total=81920000 || exit 1
